{% import "macros/utilities/standard.html" as standard %}


{%- macro sidebar_nav(type) -%}
  {%- if type == "page" -%}
    {%- set nav_icon_class = "d-none" -%}
    {%- set nav_text_class = "d-none d-md-inline" -%}
  {%- else -%}
    {%- set nav_icon_class = "d-none d-xl-inline" -%}
    {%- set nav_text_class = "d-none" -%}
  {%- endif -%}

  <div class="sidebar-nav list-group my-auto rounded-0 text-center">
    {%- for item in config.extra.menus.nav -%}
      <a
        href="{{ standard::get_url_on_location(path = item.url) }}"
        class="sidebar-nav-item list-group-item list-group-item-action border border-0"
        data-bs-toggle="tooltip" data-bs-title="{{ item.name | safe }}"
      >
        <span class="sidebar-nav-icon bi {{ item.icon | safe }} {{ nav_icon_class | safe }} fs-4"></span>
        <span class="sidebar-nav-text {{ nav_text_class | safe }}">
          {{ item.name | safe }}
        </span>
      </a>
    {%- endfor -%}
  </div>
{%- endmacro sidebar_nav -%}


{%- macro offcanvas_sidebar_nav() -%}
  <div class="sidebar-nav list-group my-auto rounded-0 text-start">
    {%- for item in config.extra.menus.nav -%}
      <a
        href="{{ standard::get_url_on_location(path = item.url) }}"
        class="sidebar-nav-item list-group-item list-group-item-action border border-0"
        data-bs-toggle="tooltip" data-bs-title="{{ item.name | safe }}"
      >
        <span class="sidebar-nav-icon bi {{ item.icon | safe }} ms-2 me-1 fs-4"></span>
        <span class="sidebar-nav-text">{{ item.name | safe }}</span>
      </a>
    {%- endfor -%}
  </div>
{%- endmacro offcanvas_sidebar_nav -%}


{%- macro social_links() -%}
  {%- if config.extra.social.links -%}
    {%- for link in config.extra.social.links -%}
      <div class="col-auto px-2">
        <a
          href="{{ link.url | safe }}"
          target="_blank" rel="noopener noreferrer"
          data-bs-toggle="tooltip"
          data-bs-title='{{ link.name | safe }}'
          class="text-decoration-none"
        >
          <span class="bi {{ link.icon | safe }}"></span>
        </a>
      </div>
    {%- endfor -%}
  {%- endif -%}
{%- endmacro social_links -%}


{%- macro top_bar_nav(page, type) -%}
  {%- if type == "page" -%}
    {%- set top_navbar_class = "justify-content-center justify-content-lg-start" -%}
  {%- else -%}
    {%- set top_navbar_class = "justify-content-center justify-content-xl-start" -%}
  {%- endif -%}

  <div class="row {{ top_navbar_class | safe }} p-2 ps-xl-3 text-center">
    {%- set page_ancestor = page.ancestors | last | safe -%}

    {%- if page_ancestor -%}
      {%- set section = get_section(path = page_ancestor) -%}
      <div class="col-auto d-none d-xl-block">
        <a
          href="{{ section.permalink | safe }}"
          class="text-decoration-none"
        >
          {{ section.title | truncate(length=40) | safe }}
        </a>
      </div>
      <div class="col-auto d-none d-xl-block">
        <span class="text-secondary">
          »
        </span>
      </div>
    {%- endif -%}

    <div class="col-auto">
      <span
        class="d-inline d-sm-none text-secondary"
        data-bs-toggle="tooltip"
        data-bs-title="{{ page.title | safe }}"
      >
        {{ page.title | truncate(length=16) | safe }}
      </span>
      <span
        class="d-none d-sm-inline text-secondary"
        data-bs-toggle="tooltip"
        data-bs-title="{{ page.title | safe }}"
      >
        {{ page.title | truncate(length=40) | safe }}
      </span>
    </div>
  </div>
{%- endmacro top_bar_nav -%}

{%- macro simple_top_bar_nav(type) -%}
  {%- if type == "page" -%}
    {%- set top_navbar_class = "justify-content-center justify-content-lg-start" -%}
  {%- else -%}
    {%- set top_navbar_class = "justify-content-center justify-content-xl-start" -%}
  {%- endif -%}

  <div class="row {{ top_navbar_class | safe }} p-2 ps-xl-3 text-center">      
    <div class="col-auto">
      <a
        href="{{ config.base_url | safe }}"
        class="d-inline d-sm-none text-decoration-none"
      >
        {{ config.title | truncate(length=16) | safe }}
      </a>
      <a
        href="{{ config.base_url | safe }}"
        class="d-none d-sm-inline text-decoration-none"
      >
        {{ config.title | truncate(length=40) | safe }}
      </a>
    </div>
  </div>
{%- endmacro simple_top_bar_nav -%}